/**
**************************************************************************************
*Founder Effect                                                                      *
*Copyright (C) 2006-2007, 5d Studios (www.5d-Studios.com)                            *
*                                                                                    *
*This library is free software; you can redistribute it and/or                       *
*modify it under the terms of the GNU Lesser General Public                          *
*License as published by the Free Software Foundation; either                        *
*version 2.1 of the License, or (at your option) any later version.                  *
*                                                                                    *
*This library is distributed in the hope that it will be useful,                     *
*but WITHOUT ANY WARRANTY; without even the implied warranty of                      *
*MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU                   *
*Lesser General Public License for more details.                                     *
*                                                                                    *
*You should have received a copy of the GNU Lesser General Public                    *
*License along with this library; if not, write to the Free Software                 *
*Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA      *
**************************************************************************************
*/
#pragma once

#include <string>
#include <map>

#ifdef _WIN32
    #include "windows.h"
#endif

#include "glfont2.h"

#include "../shared/color.h"

/**
 * Colors
 */
enum
{
    BLACK,
    WHITE,
    GREY,
    RED,
    GREEN,
    BLUE,
    ORANGE,
    PURPLE,
    LIGHT_BLUE,
    LIGHT_GREEN
};

class IRender;

/**
=====================
FontType 
=====================
*/
struct FontType : public glfont::GLFont
{
    FontType() : size(0.0f), width(0.0f), height(0.0f) {};
    std::string name;       // name of the font
    float       size;       // font size

    float       width,      // width
                height;     // height
};
/**
===========================
Manage the current display font
TODO
===========================
*/
class FontManager
{
public:
    FontManager(void);

    /** Create a font */
    bool Create( const std::string &file, const std::string &fontName );
    /** Free the font */
    void Free( const std::string &fontName );
    /** Free all */
    void FreeAll();
    /** Set Font Type */
    void SetFontType( const std::string &fontName );
    /** Set the font size */
    void SetFontSize( float size ) { m_currentFont->size = size; };
    /** Get the font size */
    float GetFontSize() { return m_currentFont->size; };
    /** Get the width of the text */
    float GetWidth() { return m_currentFont->width; };
    /** Get the height of the text */
    float GetHeight() { return m_currentFont->height; };
    /** Set the width */
    void SetWidth( float w ) { m_currentFont->width = w; };
    /** Set the height */
    void SetHeight( float h ) { m_currentFont->height = h; };

    /** Draw a String */
    void DrawString( IRender* r,  float x, float y, const char* s,... );

private:
    /** Draw out a single char */
    void DrawChar( IRender* r, int color, float x, float y, char c );
    
    // OpenGL implementation
    typedef std::map< std::string, FontType* > type_FontList;
    type_FontList  m_fonts;

    // current font
    FontType*       m_currentFont;

    // colors
    Color           m_colors[10];      // ten colors

public:
    virtual ~FontManager(void);
};
